#include"process.h"
const char* spin="|/-\\";
void process_v1()
{
   //verson 1
   char bar[size];
   memset(bar,'\0',sizeof(bar));
   int rate=0;
   while(rate<=maxrate)
   {
       printf("[%-100s][%d%%][%c]\r",bar,rate,spin[rate%strlen(spin)]);
       fflush(stdout);
       usleep(runtime);
       bar[rate++]=style;
   }
   printf("\n");
}

void process_v2(double rate)
{
    static char bar[size]={0};
    static int num=0;
    int len=strlen(spin);
    if(rate>=0.0&&rate<=maxrate)
    {
       num=(num>=len?0:num);
       printf("[%-100s][%.1f%%][%c]\r",bar,rate,spin[num]);
       fflush(stdout);
       bar[(int)rate]=style;
    }
}


